<?php

/**
 *

// 常用blade模板语法
// {{$title or '默认标题'}}  //在模板中设置变量默认值 
// {{isset($text) ? $text : '*'}}
// {!! $sciprt !!} 模板会默认过滤js,!!为不过滤
// @{{$angular}} 原样输出,防止和js框架的语法冲突

//读取自定义配置项
// echo env('DB_PREFIX');
// echo config('app.timezone');
// echo config('database.connections.mysql.charset');

 *
 **/

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use App\Models\Users;
use App\Models\Article;

class IndexController extends Controller
{
    public function index()
    {
        return view('index');
    }

    public function focus($value='')
    {
    	//session(['key' => 123]);
    	$title = '焦点聚合 - 新闻事件联合体';
    	$siteData = array(
    		'siteName' => 'ZHIGUO.ME',
    	);
		// return view('welcome',$vData);
		return view('welcome',compact('title','siteData'));
    }

    public function test($value='')
    {
    	$data = array(
    		'vOne' => 'what',
    		'vTwo' => 'what what',
    	);
    	$emptyData = array();
    	return view('test',compact('data','emptyData'));
    }

    public function dbtest()
    {
        // $pdo = DB::connection()->getPdo();
        // dd($pdo);
        // $users = DB::table('users')->get();
        // dd($users);
        // 插入文章
        // DB::table('article')->insert([
        //     ['title' => '文章1', 'cate_id' => 1],
        //     ['title' => '文章2', 'cate_id' => 2]
        // ]);
        // 查询文章列表
        // $articles = DB::table('article')->get();
        // dd($articles);
        //Eloquent ORM { --->
        // $user = Users::where('user_id',1)->get();
        // $user = Users::find(1);
        $article = Article::find(5);
        // $article->title = '文章1被修改了';
        // $article->update();
        dd($article);
        //Eloquent ORM } --->
    }

}
